//////////////////////////////////////////////////////////////////////////
// boundtopology - class to hold information about topology of boundary
// By Antonio Miranda - Fev 2013
//////////////////////////////////////////////////////////////////////////

#ifndef _BOUND_TOPOLOGY_
#define _BOUND_TOPOLOGY_

#include <vector>
#include "matrix4x4.h"

class tetraTopology;
class cTopology;

using namespace std;

//
//////////////////////////////////////////////////////////////////////////
class boundTopology
{
public:
  boundTopology(tetraTopology *tetratopol);
  ~boundTopology (void);

  void getCrackNodes (vector<int> &nodes);


  // easy accesses
  //////////////////////////////////////////////////////////////////////////

  // boundary topology
  cTopology     *m_surfTopol;

private:
  
  // build surface topology
  void buildSurfToppology ( );

  // try to identify surfaces by edges of model
  // this function also identify edges on crack tip
  void identifySurfaces ( );

  // identify cracks
  void identifyCracks ( );
  
  // mark elements/triangles/surfaces with flag
  void markSurfaces (vector<int> ids, int flag);
  
  // compute matrix transformation
  void makeCrackTransf    ( );
  void computeCrackTransf (int id_crack, int id_pos, int id_tang0, int id_tang1);
  

  // current volume topology
  tetraTopology *m_tetraTopol;

  // map node from tetraTopol and surfTopol;
  vector<int> m_mapNode;
  vector<int> m_invMapNode;

  // all edges in crack tip
  vector<int> m_crackEdges;

  // crack faces
  vector< vector<int> > m_crackFaces;
  
  // crack front
  vector< vector<int> >       m_crackFront;  // id points
  vector< vector<matrix4x4> > m_crackTransf; // transform matrix
    
    

};

#endif
